/// <summary>
//  SC2 Minimap Watcher Copyright by
/// </summary>

#include <iostream>
#include <thread>
#include <Windows.h>
#include <string>
#include "Scanner.h"

using namespace std;

int main()
{
	// input string
	string input;
	thread* scanner_run;
	// the minimap scanner
	Scanner scanner;
	
	cout << "MinimapWatcher 1.0 Alpha" << endl;
	cout << "Commandos: start, stop, exit" << endl;
	while(input != "exit")
	{
		cin >> input;

		if(input=="start")
		{
			scanner_run = new thread([&scanner]() { scanner.Start(); } );
		}
		else
			if(input=="stop")
			{
				cout << "waiting for scanner thread to quit..." << endl;
				if (scanner.Stop())
				{
					scanner_run->join();
					cout << "done!" << endl;
				}
				else
				{
					cout << "cannot stop scanner thread because it's not running!" << endl;
				}
			}
	}

	return 0;
}